home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libc / ansi / stdio / bintext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-25  |  661 b   |  33 lines

  1. #include <stdio.h>
  2. #include <io.h>
  3. #include <fcntl.h>
  4.  
  5. int
  6. main(void)
  7. {
  8.   FILE *f;
  9.  
  10.   f = fopen("/tmp/binary.dat", "wb");
  11.   fprintf(f, "hello\nthere\n");
  12.   fclose(f);
  13.  
  14.   f = fopen("/tmp/text.dat", "wt");
  15.   fprintf(f, "hello\nthere\n");
  16.   fclose(f);
  17.  
  18.   fflush(stdout);
  19.   setmode(1, O_BINARY);
  20.   printf("stdout in binary mode\nbinary\nbinary\n");
  21.   fflush(stdout);
  22.   setmode(1, O_TEXT);
  23.   printf("stdout in text mode\ntext\ntext\n");
  24.   fflush(stdout);
  25.   setmode(1, O_BINARY);
  26.   printf("stdout in binary mode\nbinary\nbinary\n");
  27.   fflush(stdout);
  28.   setmode(1, O_TEXT);
  29.   printf("stdout in text mode\ntext\ntext\n");
  30.  
  31.   return 0;
  32. }
  33.